package ioperations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList){
        Scanner scanner = new Scanner(System.in);
        System.out.println("新增图书......");
        if( bookList.getUseSize() == bookList.getBooks().length){
            System.out.println("书架已经满！");
            return ;
        }
        System.out.println("请输入你要新增书的信息：");
        int number = bookList.getUseSize();
        bookList.setUseSize(number + 1);
        System.out.print("name:");
        String name = scanner.nextLine();
        System.out.print("author:");
        String author = scanner.nextLine();
        System.out.print("type:");
        String type = scanner.nextLine();
        System.out.print("price:");
        double price = scanner.nextDouble();
        Book book = new Book(name,author,price,type);
        bookList.setBooks(number, book);
    }
}
